package com.mach.platform.api.util;

import org.apache.tomcat.util.codec.binary.Base64;

import java.io.UnsupportedEncodingException;

public class Base64Util {


    /**
     * Base64编码相应内容
     * @param content 内容
     * @return
     */
    public static String base64Coding(String content) {
        try {
            content = Base64.encodeBase64String(content.getBytes("utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return content;
    }


    /**
     * Base64解码相应内容
     * @param content 内容
     * @return
     */
    public static String base64Decoding(String content) {
        try {
            content = new String(Base64.decodeBase64(content.getBytes()), "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return content;
    }


}
